package com.minigame.rpc.network.command;

import java.util.HashMap;
import java.util.Map;

public class CommandService {

    private Map<Integer,AbstractCommand<?>> commandMap = new HashMap<>();

    private final static CommandService COMMAND_SERVICE = new CommandService();

    public static CommandService getInstance(){
        return COMMAND_SERVICE;
    }

    public void init(){
        addCommand(new HeartBeatCommand());
        addCommand(new ServerInfoCommand());
    }

    private void addCommand(AbstractCommand<?> command){
        commandMap.put(command.command(), command);
    }

    public AbstractCommand<?> getAbstractCommand(int command){
        return commandMap.get(command);
    }
}
